<template>
	<view class="item item_margin" @click="itemClick">
	
		<view style="height: 80rpx;display: flex;justify-content: space-between;align-items: center;margin-right: 20rpx;">
			<text class="title">
				订单号：{{itemData.orderCarCode}}
			</text>
	
			<text v-if="6!==itemData.rentType" style="font-size: 26rpx;color: #FFC500;border: #FFC500 2rpx solid;padding: 0 10rpx;border-radius: 6rpx;">{{itemData.tenancy|filterNull}}期</text>
		</view>
	
	
		<u-line color="#efefef" :customStyle="{'margin-bottom': '30rpx','display': 'block',}"></u-line>
	
		<view class="text-line">
			<text class="text-name">租赁类型:</text>
			<text class="text-value">{{itemData.rentTypeStr|filterNull}}</text>
			
			<text style="align-self: flex-end;color: white;font-size: 22rpx;padding: 5rpx 10rpx;background-color: #FFC500;border-radius: 50rpx 0 0 50rpx;">{{itemData.orderCarStatusStr|filterNull}}</text>
		</view>
	
		<view class="text-line">
			<text class="text-name">客户名称:</text>
			<text
				class="text-value">{{itemData.customerName|filterNull}}</text>
		</view>
	
		<view class="text-line" @click="makecall(itemData.customerTel)">
			<text class="text-name">联系电话:</text>
			<text class="text-value" style="flex-grow: unset;">{{itemData.customerTel|filterNull}}</text>
			<image style="width: 30rpx;height: 30rpx;margin-left: 10rpx;" src="../../static/common/callPhone.png" mode="scaleToFill"></image>
		</view>
	
		<view class="text-line" v-if="1==itemData.rentType||2==itemData.rentType||3==itemData.rentType||4==itemData.rentType||5==itemData.rentType">
			<text class="text-name">租期:</text>
			<text class="text-value">{{itemData.timeRent|filterNull}}</text>
		</view>
	
		<view class="text-line">
			<text class="text-name">车牌号:</text>
			<text class="text-value">{{itemData.carNo|filterNull}}</text>
		</view>
	
		<view class="text-line">
			<text class="text-name">品牌/车系/车型:</text>
			<text class="text-value">{{itemData.brandSeriesModelName|filterNull}}</text>
		</view>
	
		<view class="text-line" v-if="5==itemData.rentType">
			<text class="text-name">金融公司:</text>
			<text class="text-value">{{itemData.repaymentMethods|filterNull}}</text>
		</view>
	
		<view class="text-line" v-if="itemData.placeOrderTypeStr">
			<text class="text-name" style="color: #1573FF;">{{itemData.placeOrderTypeStr|filterNull}}</text>
		</view>
	
		<view class="text-line" v-for="(fitem, findex) in itemData.planMoneyList" :key="findex">
			<text class="text-name">{{fitem.moenyDesc|filterNull}}</text>
			<text class="text-value">¥{{fitem.moenyAmount|filterNull}}</text>
		</view>
		
		
		<view class="btn-content">
			<text v-for="(bitem, bindex) in itemData.buttonList" :key="bindex" @click="btnClick(bitem)">{{bitem.btnName}}</text>
		</view>
		
		
		<view class="text-line" style="justify-content: flex-end;" v-if="itemData.approveStatusStr">
			<text class="text-name" style="color: #FFC500;margin-right: 20rpx;">{{itemData.approveStatusStr|filterNull}}</text>
		</view>
		
		<view class="text-line" style="justify-content: flex-end;" v-if="itemData.nextNodeApproveName">
			<text class="text-name" style="color: #FFC500;margin-right: 20rpx;">{{itemData.nextNodeApproveName|filterNull}}</text>
		</view>
		
		<view class="text-line" style="justify-content: flex-end;" v-if="itemData.swopDesc">
			<text class="text-name" style="color: #FFC500;margin-right: 20rpx;">{{itemData.swopDesc|filterNull}}</text>
		</view>
		
		<view class="text-line" style="justify-content: flex-end;" v-if="itemData.transferTime">
			<text class="text-name" style="color: #FFC500;margin-right: 20rpx;">{{itemData.transferTime|filterNull}}</text>
		</view>
		
		<view class="text-line" style="justify-content: flex-end;" v-if="itemData.spareCarDesc">
			<text class="text-name" style="color: #FFC500;margin-right: 20rpx;">{{itemData.spareCarDesc|filterNull}}</text>
		</view>
		
		
	
	</view>
	
</template>

<script>
	export default {
		name:'order-list-item',
		data(){
			return{
				
			}
		},
		props:{
			itemData:{
				type:Object,
				default:()=>{
					return {}
				}
			}
		},
		methods:{
			makecall(phone){
				if(!uni.$u.test.isEmpty(phone)){
					uni.makePhoneCall({
						phoneNumber:phone
					})
				}
			},
			
			itemClick(){
				this.$emit('itemClick', this.itemData)
			},
			
			/**
			 * 提单审核分配交车:301
			 * 提单审核通过:302
			 * 提单审核驳回:303
			 * 提单审核拒绝:304
			 * 提单审核撤回:305
			 * 提单审核删除:306
			 * 提单审核详情(订单是审核中，拒绝等操作):307
			 * 提单驳回重新编辑/编辑:308
			 * 提交 10
			 * 暂存 9
			 *
			 * 提单无工作流：
			 * 订单过户 8
			 * 订单费用减免 7
			 * 订单申请换车 6
			 * 订单申请退车 5
			 * 订单分配交车 4
			 * 订单详情 3
			 * 订单修改 2
			 * 订单删除 1
			 *
			 * 退换车有工作流：
			 * 退换车重新编辑:401
			 * 退换车审批通过:402
			 * 退换车审批驳回:403
			 * 退换车审批拒绝:404
			 * 退换车审批撤回:405
			 */
			btnClick(item){
				
				let activeEnable = this.$store.state.params.activitiEnable
				
				
				switch(item.btnKey){
					case '1':
					case '306':
						uni.navigateTo({
							url: '/pagesB/exam-order/exam-order?type=6&orderId=' + this.itemData.orderId
						})
						break
					case '2':
					
						let hasWorkFlow = false;
						if (1==this.itemData.rentType || 3==this.itemData.rentType || 4==this.itemData.rentType) {
							//经租/展示车/试驾车
							if (1 == activeEnable.longRentOrderApprove) {
								//长租有审批流
								hasWorkFlow = true;
							} else {
								//长租无审批流
								hasWorkFlow = false;
							}

						} else if (2==this.itemData.rentType) {
							//租售
							if (1 == activeEnable.rentSaleOrderApprove) {
								//租售有审批流
								hasWorkFlow = true;
							} else {
								//租售无审批流
								hasWorkFlow = false;
							}
						} else if (5==this.itemData.rentType) {
							//融租
							if (1 == activeEnable.meltsRentOrderApprove) {
								//融租有审批流
								hasWorkFlow = true;
							} else {
								//融租无审批流
								hasWorkFlow = false;
							}
						} else if (6==this.itemData.rentType) {
							//直购
							if (1 == activeEnable.purchaseOrderApprove) {
								//直购有审批流
								hasWorkFlow = true;
							} else {
								//直购无审批流
								hasWorkFlow = false;
							}
						}

						if (hasWorkFlow) {
							uni.navigateTo({
								url:'/pagesB/addorder/addorder-workflow?orderId='+this.itemData.orderId
							})
						} else {
							uni.navigateTo({
								url:'/pagesB/addorder/addorder?orderId='+this.itemData.orderId
							})
						}
					
						break
					case '3':
						getApp().globalData.orderListBean = this.itemData
						uni.navigateTo({
							url: '/pagesB/orderdetail/orderdetail'
						})
						
						break
					case '4':
					case '301':
						uni.navigateTo({
							url: '/pagesB/distributecar/distributecar?orderCarId=' + this.itemData.orderCarId
						})
						break
					case '5':
						let flag = false;
						if (1 == this.itemData.rentType) {
							//长租退车
							flag = 1 == activeEnable.carBackApprove;
						} else if (2 == this.itemData.rentType) {
							//租售退车
							flag = 1 == activeEnable.rentSaleApprove;
						}else if(6 == this.itemData.rentType){
							//直购退车
							flag = 1 == activeEnable.purchaseBackApprove;
						}
					
						if (flag) {
							//有工作流
							uni.navigateTo({
								url: '/pagesB/refundandchange/refundchange-workflow?returnCarType=2&rentType=' +
									this.itemData.rentType + '&orderCarNo=' + this.itemData.orderCarCode+
									'&orderCarId='+this.itemData.orderCarId+'&instanceId='+this.itemData.instanceId
							})
						} else {
							uni.navigateTo({
								url: '/pagesB/refundandchange/refundchange?returnCarType=2&rentType=' + this.itemData
									.rentType + '&orderCarNo=' + this.itemData.orderCarCode+
									'&orderCarId='+this.itemData.orderCarId
							})
					
						}
					
						break
					case '6':
						let flag2 = false;
						if (1 == this.itemData.rentType) {
							//长租换车
							flag2 = 1 == activeEnable.rentTransferCar;
						} else if (2 == this.itemData.rentType) {
							//租售换车 ???
							flag2 = 1 == activeEnable.rentSaleTransferCar;
						}
					
						if (flag2) {
							//有工作流
							uni.navigateTo({
								url: '/pagesB/refundandchange/refundchange-workflow?returnCarType=1&rentType=' +
									this.itemData.rentType + '&orderCarNo=' + this.itemData.orderCarCode+
									'&orderCarId='+this.itemData.orderCarId+'&instanceId='+this.itemData.instanceId
							})
					
						} else {
					
							uni.navigateTo({
								url: '/pagesB/refundandchange/refundchange?returnCarType=1&rentType=' + this.itemData
									.rentType + '&orderCarNo=' + this.itemData.orderCarCode+
									'&orderCarId='+this.itemData.orderCarId
							})
					
						}
					
						break
					case '8':
					
						if(!uni.$u.test.isEmpty(this.itemData.carId)){
							uni.navigateTo({
								url: '/pagesA/assign/assign?carId=' + this.itemData.carId
							})
						}
					
						break
					case '302':
						uni.navigateTo({
							url: '/pagesB/exam-order/exam-order?type=3&orderId=' + this.itemData.orderId
						})
						break
					case '303':
						uni.navigateTo({
							url: '/pagesB/exam-order/exam-order?type=2&orderId=' + this.itemData.orderId
						})
						break
					case '304':
						uni.navigateTo({
							url: '/pagesB/exam-order/exam-order?type=1&orderId=' + this.itemData.orderId
						})
						break
					case '305':
						uni.navigateTo({
							url: '/pagesB/exam-order/exam-order?type=5&orderId=' + this.itemData.orderId
						})
						break
					case '307':
						getApp().globalData.orderListBean = this.itemData
					
						uni.navigateTo({
							url: '/pagesB/exam-order/exam-orderdetail'
						})
						break
					case '308':
						uni.navigateTo({
							url: '/pagesB/addorder/addorder-workflow?orderId=' + this.itemData.orderId
						})
						break
					case '401':
					case '407':
						if (uni.$u.test.isEmpty(this.itemData.returnCarType) ||
							uni.$u.test.isEmpty(this.itemData.orderCarCode) ||
							uni.$u.test.isEmpty(this.itemData.alterationInstanceId) ||
							uni.$u.test.isEmpty(this.itemData.rentType) ||
							uni.$u.test.isEmpty(this.itemData.orderCarStatusStr)
						) {
							this.$u.toast('数据异常')
							return
						}
						
						uni.navigateTo({
							url: '/pagesB/refundandchange/refundchange-detail-workflow?returnCarType=' + this.itemData
								.returnCarType +
								'&orderCarId='+itemData.orderCarId+'&orderCarNo=' + this.itemData.orderCarCode + '&instanceId=' + this.itemData.alterationInstanceId +
								'&rentType=' + this.itemData.rentType +
								'&orderCarStatusStr=' + this.itemData.orderCarStatusStr
						})
						break
				}
			},
			
		}
		
	}
</script>

<style lang="scss" scoped>
	.title {
		width: 80%;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		color: $black33;
		margin-left: 20rpx;
	}
	
	.btn-content{
		display: flex;
		flex-wrap: wrap;
		margin: 0 0 20rpx 20rpx;
		justify-content: flex-end;
		
		
		text{
			width: 150rpx;
			line-height: 60rpx;
			text-align: center;
			color: #fff;
			border-radius: 90rpx;
			background-color: #1573FF;
			font-size: 26rpx;
			margin: 10rpx 20rpx 0 0;
		}
	}
</style>